import pandas as pd
import tushare as ts

frame = ts.get_k_data('600339', start='2010-01-01', end='2010-10-31')
frame.index = pd.to_datetime(frame['date'])
print(frame.head())

# 查询股票收盘价大于11的所有交易记录
print(frame[frame.close > 11])

# 查询盈利的交易记录
print(frame[frame.close > frame.open])

# 利用股票收盘价和开盘价计算盈利额
print((frame.close - frame.open).sum() * 100)

newFrame = frame[frame.close > frame.open]
print((newFrame.close - frame.open).sum() * 100)